from haystack import indexes

from goods.models import Goods


class GoodsIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True,use_template=True)

    def get_model(self):
        # 是指定搜索的模型类为goods
        return Goods

    def index_queryset(self, using=None):
        """创建索引的字段"""
        return self.get_model().objects.all()